using System;
using System.Collections.Generic;
using System.Text;
using DAL.DateSet.ProduceLocationTableAdapters;
using System.Data;
using DAL;

namespace BLL.Wrapper
{
    class ProduceLoacationWrapper : ProduceLocationTableAdapter
    {

        public List<string> getProvince()
        {
            string sql = "select locationName from ProduceLocation where parentID = 0";
            DataTable table = new DataTable();
            List<string> list = new List<string>();
            HouseDiyHelper helper = HouseDiyHelper.GetInstance();
            table = helper.getResultBySql(sql);
            for (int i = 0; i < table.Rows.Count; i++)
            {
                list.Add(table.Rows[i][0].ToString());
            }
            return list;
        }

        public List<string> getCityName(string name)
        {
            string sql = "select locationID from ProduceLocation where locationName = '" + name + "'";
            DataTable table = new DataTable();
            List<string> list = new List<string>();
            HouseDiyHelper helper = HouseDiyHelper.GetInstance();
            table = helper.getResultBySql(sql);
            int id = Convert.ToInt32(table.Rows[0][0].ToString());
            sql = "select locationName from ProduceLocation where parentID = " + id.ToString();
            table.Clear();
            table = helper.getResultBySql(sql);
            for (int i = 0; i < table.Rows.Count; i++)
            {
                list.Add(table.Rows[i][0].ToString());
            }
            return list; 
        }
    }
}
